
/*
basis is like express
write by wuweiwei
*/

var basis = require("node-basis");
var querystring = require('querystring');
basis.setRouter({
	"interface":"/restful/upload" /*you can send ajax to request url*/
});
basis.controller("interface",function(req,res,argv){
	var body = '';
	req.on('data',function(chunk){
		body += chunk;
	});

	req.on('end', function () {
		//body = querystring.parse(body);  //将一个字符串反序列化为一个对象
		//res.end(body);
		var posStart = body.indexOf("------WebKitFormBoundaryuP1WvwP2LyvHpNCi\r\n") + 42;	
		fs.writeFile('/uploadFiles/xxx.png', '我是通过写入的文件内容！',  function(err) {

		});
	});
});

// basis.controller("interface",function(req,res,argv){
// 	res.writeHead(200,{'content-type':'application/json'});
// 	res.write('{"code":0,"data":[{"status":1,"title":"测试项目工艺深化图纸","planStartDate":"2018.1.12","planFinishDate":"2018-2-2"}]}');
// 	res.end();
// });

basis.run(80); /*listener 80 port*/

/*
注意：在浏览器中输入 localhost/index.html
*/

